#!/usr/bin/python

"""gen_day.py

this script is
"""

__author__ = 'takahiro'
__version__ = '2014-02-10 1.00 (takahiro)'

import sys
import optparse
from datetime import date

usage = "%prog [options] [filename]"
parser = optparse.OptionParser( usage=usage )
parser.parse_args( )

if len( sys.argv ) == 1:
  stream = sys.stdin
elif len( sys.argv ) == 2:
  stream = open( sys.argv[ 1 ], 'r' )
else:
  parser.print_help( )
  exit( )

keys = open('format.org', 'r').readlines()[0].rstrip().split(' ')

for line in stream:
  array = line.rstrip().split('\t')
  (y, m, d) = array[keys.index('date')].split('/')
  print date(int(y), int(m), int(d)).weekday()
  
